package solutions.leetcode.easy

/**
 * @author lizhidong
 * <a href="https://leetcode.cn/problems/alternating-digit-sum/">2544. 交替数字和</a>
 */
private class Solution2544 {
    fun alternateDigitSum(n: Int): Int {
        var a = 1
        var rst: Long = 0
        for (item in n.toString()) {
            rst += a * (item - '0')
            a *= -1
        }
        return rst.toInt()
    }
}

fun main() {
    
}